package 笔试.a4399;

/**
 * @author:谢君臣
 * @Date:2021/9/28-20:58
 * @version:1.0
 * @function:
 */

import java.util.*;
public class Main{
    public static void main (String[] args) {
        /* code */
        Scanner scanner = new Scanner(System.in);
        StringBuilder str = new StringBuilder(scanner.nextLine());
        StringBuilder res = function(str);
        System.out.println(res);
    }
    public static StringBuilder function(StringBuilder str){
        List<Integer> list = new ArrayList<>();
        int l = 0;
        while (l<str.length()){
            if (str.charAt(l)=='[') list.add(l++);
            else if (str.charAt(l)==']'){
                Integer start = list.remove(list.size() - 1)+1;
                StringBuilder num = new StringBuilder();
                int i =start;
                while (str.charAt(i)!='|')
                    num.append(str.charAt(i++));
                StringBuilder com = new StringBuilder(str.substring(++i,l));
                StringBuilder complex = new StringBuilder();
                i = Integer.parseInt(num.toString());
                while (i>0){complex.append(com);i--;}
                str = new StringBuilder(str.substring(0,start-1) + complex + str.substring(++l));
            }else l++;
        }
        return str;
    }

}
